package com.ericsson.resourceplanner.dao.entity;

import java.io.Serializable;

import javax.persistence.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the EMPLOYEE_PROJECT database table.
 * 
 */
@Entity
@Table(name="EMPLOYEE_PROJECT")
public class EmployeeProject implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="EMPLOYEE_PROJECT_ID_GENERATOR", sequenceName="ORDER_SEQUENCE")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EMPLOYEE_PROJECT_ID_GENERATOR")
	private long id;

	@Temporal(TemporalType.DATE)
	@Column(name="END_DATE")
	private Date endDate;

	private BigDecimal fte;

	@Temporal(TemporalType.DATE)
	@Column(name="START_DATE")
	private Date startDate;

	private String status;

	//bi-directional many-to-one association to Employee
	@ManyToOne
	private Employee employee;

	//bi-directional many-to-one association to Project
	@ManyToOne
	private Project project;

	//bi-directional many-to-one association to WeekUtilization
	@OneToMany(mappedBy="employeeProject")
	private List<WeekUtilization> weekUtilizations;

	public EmployeeProject() {
	}

	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public BigDecimal getFte() {
		return this.fte;
	}

	public void setFte(BigDecimal fte) {
		this.fte = fte;
	}

	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Employee getEmployee() {
		return this.employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public List<WeekUtilization> getWeekUtilizations() {
		return this.weekUtilizations;
	}

	public void setWeekUtilizations(List<WeekUtilization> weekUtilizations) {
		this.weekUtilizations = weekUtilizations;
	}

	public WeekUtilization addWeekUtilization(WeekUtilization weekUtilization) {
		getWeekUtilizations().add(weekUtilization);
		weekUtilization.setEmployeeProject(this);

		return weekUtilization;
	}

	public WeekUtilization removeWeekUtilization(WeekUtilization weekUtilization) {
		getWeekUtilizations().remove(weekUtilization);
		weekUtilization.setEmployeeProject(null);

		return weekUtilization;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((employee == null) ? 0 : employee.hashCode());
		result = prime * result + ((endDate == null) ? 0 : endDate.hashCode());
		result = prime * result + ((fte == null) ? 0 : fte.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((project == null) ? 0 : project.hashCode());
		result = prime * result
				+ ((startDate == null) ? 0 : startDate.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime
				* result
				+ ((weekUtilizations == null) ? 0 : weekUtilizations.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EmployeeProject other = (EmployeeProject) obj;
		if (employee == null) {
			if (other.employee != null)
				return false;
		} else if (!employee.equals(other.employee))
			return false;
		if (endDate == null) {
			if (other.endDate != null)
				return false;
		} else if (!endDate.equals(other.endDate))
			return false;
		if (fte == null) {
			if (other.fte != null)
				return false;
		} else if (!fte.equals(other.fte))
			return false;
		if (id != other.id)
			return false;
		if (project == null) {
			if (other.project != null)
				return false;
		} else if (!project.equals(other.project))
			return false;
		if (startDate == null) {
			if (other.startDate != null)
				return false;
		} else if (!startDate.equals(other.startDate))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (weekUtilizations == null) {
			if (other.weekUtilizations != null)
				return false;
		} else if (!weekUtilizations.equals(other.weekUtilizations))
			return false;
		return true;
	}

	
	
	
	
}